class CommunityController < ApplicationController
  layout "m"
  
  def index
    @announcements = Announcement.find(:all)
  end
  
  def new
    @announcement = Announcement.new(params[:announcement])
    return unless request.post?
    if @announcement.save
      flash[:notice] = 'Announcement was successfully created.'
      redirect_to :action => :index
    end
  end
  
  def show
    @announcement = Announcement.find(params[:id])
  end

  def edit
    @announcement = Announcement.find(params[:id])
    return unless request.post?
    if @announcement.update_attributes(params[:announcement])
      flash[:notice] = 'Announcement was successfully updated.'
      redirect_to :action => :index
    end
  end

  def destroy
    @announcement = Announcement.find(params[:id])
    @announcement.destroy
    redirect_to :action => :index
  end
end
